package com.sky.mapper;

/**
 * @Author 褚金龙
 * @Date 2024/9/24 16:01
 */

import com.sky.entity.ShoppingCart;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * 添加购物车
 */
@Mapper
public interface ShoppingCartMapper {
    /**
     * 查询购物车
     * @param shoppingCart
     * @return
     */
    List<ShoppingCart> list(ShoppingCart shoppingCart);

    /**
     * 根据id修改购物车商品数量
     */

    @Update("update shopping_cart set number=#{number} where id=#{id}")
    void updateNumberById (ShoppingCart cart);


    /**
     * 添加购物车数据
     * @param shoppingCart
     */

    void insert(ShoppingCart shoppingCart);

    /**
     * 修改购物车菜品数量
     * @param count
     */
    @Update("update shopping_cart set number=#{count} where id=#{id}")
    void updateCount(Integer count,Long id);


    /**
     * 根据id删除对应的菜品或套餐
     * @param id
     */
     @Delete("delete from shopping_cart where id=#{id}")
    void deleteShopCart(Long id);

    /**
     * 清空购物车
     */
    @Delete("delete from shopping_cart where user_id=#{currentId}" )
    void deleteCart(Long currentId);

    /* *//**
     * 根据用户Id查询购物车
     * @return
     *//*

    @Select("select *from shopping_cart where user_id=#{userId}")
    List<ShoppingCart> queryShoppingCart(Long userId);*/
}
